﻿using System;
using System.Collections.Generic;
using System.Text;
using SpoonCore2.Client;

namespace SpoonCore2.Routing
{
	class TableList : ITable
	{
		private readonly List<ITable> _list = new List<ITable>();

		public void Add(ClientInfo client)
		{
			foreach (ITable table in _list)
			{
				table.Add(client);
			}
		}

		public ClientInfo FindNext(SpoonIdentifier id)
		{
			ClientInfo res = null;
			foreach (ITable table in _list)
			{
				
			}
			return res;
		}

		public IList<ClientInfo> Clients
		{
			get
			{
				List<ClientInfo> res = new List<ClientInfo>();
				foreach(ITable table in _list)
				{
					foreach (ClientInfo client in table.Clients)
					{
						if(!res.Contains(client)) res.Add(client);
					}
				}
				return res;
			}
		}

		public void Remove(ClientInfo client)
		{
			foreach (ITable table in _list)
			{
				table.Remove(client);
			}
		}

		public bool Check(List<ClientInfo> clients)
		{
			bool status = true;
			foreach (ITable table in _list)
			{
				if (!table.Check(clients)) status = false;
			}
			return status;
		}

		public void Refresh()
		{
			foreach (ITable table in _list)
			{
				table.Refresh();
			}
		}
	}
}
